package com.song.tools.songtest.convertor;

import com.song.tools.mvc.convertor.AggregationConvertor;
import com.song.tools.songtest.beans.bo.DictionaryDetailBo;
import com.song.tools.songtest.beans.poi.DictionaryDetailExportDto;
import com.song.tools.songtest.beans.poi.DictionaryDetailImportDto;
import com.song.tools.songtest.beans.query.DictionaryDetailQuery;
import com.song.tools.songtest.beans.request.DictionaryDetailQueryRequest;
import com.song.tools.songtest.beans.request.DictionaryDetailSaveRequest;
import com.song.tools.songtest.beans.request.DictionaryDetailUpdateRequest;
import com.song.tools.songtest.beans.response.DictionaryDetailQueryResponse;
import com.song.tools.songtest.beans.response.DictionaryDetailSaveResponse;
import com.song.tools.songtest.beans.response.DictionaryDetailUpdateResponse;
import com.song.tools.songtest.constants.StatusEnum;
import com.song.tools.songtest.dao.entity.DictionaryDetail;
import org.mapstruct.AfterMapping;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.ReportingPolicy;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 字典明细表 转换器
 * </p>
 *
 * @author song tools
 * @since 2024-07-12
 */
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public abstract class DictionaryDetailConvertor implements AggregationConvertor<DictionaryDetail, DictionaryDetailBo, DictionaryDetailQuery, DictionaryDetailQueryRequest, DictionaryDetailQueryResponse,
        DictionaryDetailSaveRequest, DictionaryDetailSaveResponse, DictionaryDetailUpdateRequest, DictionaryDetailUpdateResponse, DictionaryDetailImportDto, DictionaryDetailExportDto> {

    @Override
    public abstract DictionaryDetail entityBoToEntity(DictionaryDetailBo dictionaryDetailBo);

    @Override
    public abstract DictionaryDetailBo entityToEntityBo(DictionaryDetail dictionaryDetail);

    @Override
    public abstract DictionaryDetailQueryResponse entityBoToQueryResponse(DictionaryDetailBo dictionaryDetailBo);

    @Override
    public abstract DictionaryDetailQuery queryRequestToQuery(DictionaryDetailQueryRequest queryRequest);

    @Override
    public abstract DictionaryDetailBo saveRequestToEntityBo(DictionaryDetailSaveRequest request);

    @Override
    public abstract DictionaryDetailSaveResponse entityBoToSaveResponse(DictionaryDetailBo dictionaryDetailBo);

    @Override
    public abstract DictionaryDetailBo updateRequestToEntityBo(DictionaryDetailUpdateRequest request);

    @Override
    public abstract DictionaryDetailUpdateResponse entityBoToUpdateResponse(DictionaryDetailBo dictionaryDetailBo);

    @Override
    public abstract List<DictionaryDetail> entityBoToEntity(List<DictionaryDetailBo> entityBo);

    @Override
    public abstract List<DictionaryDetailBo> entityToEntityBo(List<DictionaryDetail> entity);

    @Override
    public abstract DictionaryDetailExportDto entityBoToExportDto(DictionaryDetailBo entityBo);

    @Override
    public abstract DictionaryDetailBo importDtoToEntityBo(DictionaryDetailImportDto importDto);

    @Override
    public abstract List<DictionaryDetailBo> importDtoToEntityBo(List<DictionaryDetailImportDto> importDto);


    @AfterMapping
    public void afterMappingEntityBoToEntity(@MappingTarget DictionaryDetail dictionaryDetail, DictionaryDetailBo dictionaryDetailBo) {
        // entityBoToEntity() 内部其它代码执行完之后，最后会自动执行 afterMappingEntityBoToEntity()
    }

    @AfterMapping
    public void afterMappingEntityToEntityBo(@MappingTarget DictionaryDetailBo dictionaryDetailBo, DictionaryDetail dictionaryDetail) {
        // entityToEntityBo() 内部其它代码执行完之后，最后会自动执行 afterMappingEntityToEntityBo()
    }

    @AfterMapping
    public void afterMappingQueryRequestToQuery(@MappingTarget DictionaryDetailQuery dictionaryDetailQuery, DictionaryDetailQueryRequest dictionaryDetailQueryRequest) {
        // queryRequestToQuery() 内部其它代码执行完之后，最后会自动执行 afterMappingQueryRequestToQuery()
    }

    @AfterMapping
    public void afterMappingEntityBoToQueryResponse(@MappingTarget DictionaryDetailQueryResponse dictionaryDetailQueryResponse, DictionaryDetailBo dictionaryDetailBo) {
        // entityBoToQueryResponse() 内部其它代码执行完之后，最后会自动执行 afterMappingEntityBoToQueryResponse()
    }

    @AfterMapping
    public void afterMappingEntityBoToSaveResponse(@MappingTarget DictionaryDetailSaveResponse dictionaryDetailSaveResponse, DictionaryDetailBo dictionaryDetailBo) {
        // entityBoToSaveResponse() 内部其它代码执行完之后，最后会自动执行 afterMappingEntityBoToSaveResponse()
    }

    @AfterMapping
    public void afterMappingSaveRequestToEntityBo(@MappingTarget DictionaryDetailBo dictionaryDetailBo, DictionaryDetailSaveRequest dictionaryDetailSaveRequest) {
        // saveRequestToEntityBo() 内部其它代码执行完之后，最后会自动执行 afterMappingSaveRequestToEntityBo()
    }

    @AfterMapping
    public void afterMappingEntityBoToUpdateResponse(@MappingTarget DictionaryDetailUpdateResponse dictionaryDetailUpdateResponse, DictionaryDetailBo dictionaryDetailBo) {
        // entityBoToUpdateResponse() 内部其它代码执行完之后，最后会自动执行 afterMappingEntityBoToUpdateResponse()
    }

    @AfterMapping
    public void afterMappingUpdateRequestToEntityBo(@MappingTarget DictionaryDetailBo dictionaryDetailBo, DictionaryDetailUpdateRequest dictionaryDetailUpdateRequest) {
        // updateRequestToEntityBo() 内部其它代码执行完之后，最后会自动执行 afterMappingUpdateRequestToEntityBo()
    }

    @AfterMapping
    public void afterMappingImportDtoToEntityBo(@MappingTarget DictionaryDetailBo dictionaryDetailBo, DictionaryDetailImportDto dictionaryDetailImportDto) {
        // importDtoToEntityBo() 内部其它代码执行完之后，最后会自动执行 afterMappingImportDtoToEntityBo()
    }

    @AfterMapping
    public void afterMappingEntityBoToExportDto(@MappingTarget DictionaryDetailExportDto dictionaryDetailExportDto, DictionaryDetailBo dictionaryDetailBo) {
        // entityBoToExportDto() 内部其它代码执行完之后，最后会自动执行 afterMappingEntityBoToExportDto()
    }

    public Integer statusEnumToInteger(StatusEnum statusEnum) {
        if (Objects.isNull(statusEnum)) {
            return null;
        }
        return statusEnum.getCode();
    }

    public StatusEnum integerToStatusEnum(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }
        return StatusEnum.of(code);
    }
}
